#include "stdio.h"

int main()
{}

void draw1()
{
    SDL_Rect src = {0,0, img->w, img->h};

    SDL_BlitSurface(img, &src, screen, &src);

    SDL_Color color = {255, 0, 0};
    SDL_Surface * text = TTF_RenderUTF8_Blended(font, "Hello World!", color);

    SDL_Rect srcT = {0, 0, text->w, text->h};

    SDL_BlitSurface(text, &srcT, screen, &srcT);

    SDL_UpdateWindowSurface(window);

    SDL_FillRect(img, &src, 0xffffff);
    SDL_UpdateWindowSurface(win);
    SDL_Delay(1000);

    SDL_BlitSurface(img_bmp, &src, screen, &src);
    SDL_UpdateWindowSurface(win);
    
}

void draw2()
{
    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
    SDL_RenderClear(renderer);

    SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);

    SDL_RenderDrawLine(renderer, 50, 50, 100, 100);

    SDL_Point points[3] = {
        {50, 50},{100, 100}, {400, 100}
    };

    SDL_RenderDrawLines(renderer, points, 3);
    
    SDL_RenderPresent(renderer);
}

void draw4()
{
    SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
    SDL_RenderClear(renderer);

    int w, h;
    SDL_QueryTexture(ball_Texture, NULL, NULL, &w, &h);
    SDL_Rect srcRect = {0,0, w, h};
    SDL_Rect desRect = {0,0, WIDTH, HEIGHT};

    static float x = 0;
    x+= 0.1f;
    float scale = sinf(x) + 0.1;

    SDL_RenderSetScale(renderer, scale+10, scale+10);

    SDL_RenderCopy(renderer, ball_Texture, &srcRect, &desRect);

    static double angle = 0;
    angle+=2;
    SDL_RenderCopyEx(renderer, imageTexture, NULL, NULL, angle, NULL, SDL_FLIP_NONE);

    SDL_RenderPresent(renderer);
}


void destroy_Balls()
{
    for (int i=0; i<BALL_COUNT; ++i) {
        Ball_Destroy(balls[i]);
    }
}

void create_Balls()
{
    for (int i=0; i<BALL_COUNT; ++i) {
        balls[i] = Ball_Create(110*i, 10, (rand()%10)-5, (rand()%5)+1, (rand()%5)+1);
    }
}

void create_Balls();
void destroy_Balls();
Ball *balls[BALL_COUNT];



    // img = IMG_Load("pikachu.jpg");
    // if (img == NULL) {
    //     SDL_Log("Can not load image, %s", SDL_GetError());
    //     return 1;
    // }

    // if (TTF_Init()) {
    //     SDL_Log("Can not init ttf, %s", TTF_GetError());
    //     return 1;
    // }
    // font = TTF_OpenFont("OpenSans-Regular.ttf", FONT_SIZE);
    // if (font == NULL) {
    //     SDL_Log("Can not open font");
    //     return 1;
    // }

    // if (Resource_Load(renderer)) {
    //     return 1;
    // }

    // create_Balls();


    // destroy_Balls();

    // TTF_CloseFont(font);
    // SDL_FreeSurface(img);
    // SDL_FreeSurface(img_bmp);
    // SDL_FreeSurface(screen);
    // Resource_Unload();



    screen = SDL_GetWindowSurface(window);
    if (screen == NULL) {
        SDL_Log("Can not create Surface, %s", SDL_GetError());
        return 1;
    }